package model;

import java.text.SimpleDateFormat;

import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;

import org.joda.time.DateTime;
import org.joda.time.LocalDate;

public enum AlarmClockWrapperColumn implements SingleMapper<AlarmClockWrapper> {
	STARTDATE("Начальная дата", 50) {
		@Override
		public Object getValue(AlarmClockWrapper v) {
			return v.getStartDate();
		}
		@Override
		public String format(Object obj) {
			return sdf1.format(((LocalDate) obj).toDate());
		}
	},
	ENDDATE("Конечная дата", 50) {
		@Override
		public Object getValue(AlarmClockWrapper v) {
			return v.getEndDate();
		}
		@Override
		public String format(Object obj) {
			return sdf1.format(((LocalDate) obj).toDate());
		}
	},
	TIME("Время", 50) {
		@Override
		public Object getValue(AlarmClockWrapper v) {
			return v.getTime();
		}
		@Override
		public String format(Object obj) {
			return sdf.format(((DateTime) obj).toDate());
		}
	},
	TYPE("Тип", 50) {
		@Override
		public Object getValue(AlarmClockWrapper v) {
			return v.getType();
		}
		@Override
		public String format(Object obj) {
			if(obj == null)
				return " ";
			return ((AlarmTypeWrapper) obj).getDescription();
		}
	};
	private static  SimpleDateFormat sdf = new SimpleDateFormat(
            "yyyy-MM-dd HH:mm");
	private static  SimpleDateFormat sdf1 = new SimpleDateFormat(
            "yyyy-MM-dd");
	private String columnName;
	private Integer size;
	private AlarmClockWrapperColumn(String name, int size) {
		this.columnName = name;
		this.size = size;
	}
	
	@Override
	public TableCellRenderer getCellRenderer() {
		return null;
	}
	@Override
	public Class<?> getColumnClass() {
		return null;
	}
	@Override
	public String columnName() {
		return columnName;
	}
	@Override
	public int getWidth() {
		return size;
	}
	@Override
	public Object getValue(AlarmClockWrapper v) {
		return null;
	}
	@Override
	public void setValue(AlarmClockWrapper v, Object obj) {}
	
	@Override
	public boolean isCellEditable(AlarmClockWrapper v) {
		return false;
	}
	@Override
	public String format(Object obj) {
		return null;
	}
	@Override
	public TableCellEditor getEditor() {
		return null;
	}
}
